#include "PrintText.h"
#include "Screen.h"
#include "Game.h"


void PrintText2D(float x, float y, const std::string& text, Vec3f Color, float RotationAngle, const Vec3f& RotationAxis)
{
	glDisable(GL_TEXTURE_2D);
	glDisable(GL_LIGHTING);
	glMatrixMode(GL_PROJECTION);
	double *matrix = new double[16];
	glGetDoublev(GL_PROJECTION, matrix);
	glLoadIdentity();
	gluOrtho2D(0, 1280, 0, 720);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glPushMatrix();
	glLoadIdentity();

	glColor3f(Color.m_x, Color.m_y, Color.m_z);
	glRotatef(RotationAngle, RotationAxis.m_x, RotationAxis.m_y, RotationAxis.m_z);
	glRasterPos2f(x, y); 
	for (unsigned int k=0; k < text.size(); k++)
	{
		glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, text[k]);
	}

	glPopMatrix();
	//glMatrixMode(GL_PROJECTION);
	//glLoadMatrixd(matrix);
	//glMatrixMode(GL_MODELVIEW);
	//glLoadIdentity();


	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(45, 1.9, 1, 10000);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glEnable(GL_TEXTURE_2D);
	

	glColor3f(1, 1, 1);

}

void PrintText2D(float x, float y, const std::string& text, Vec3f Color)
{
	glDisable(GL_TEXTURE_2D);
	glDisable(GL_LIGHTING);
	glMatrixMode(GL_PROJECTION);
	double *matrix = new double[16];
	glGetDoublev(GL_PROJECTION, matrix);
	glLoadIdentity();
	gluOrtho2D(0, 1280, 0, 720);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glPushMatrix();
	glLoadIdentity();

	glColor3f(Color.m_x, Color.m_y, Color.m_z);
	glRasterPos2f(x, y); 
	for (unsigned int k=0; k < text.size(); k++)
	{
		glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, text[k]);
	}

	glPopMatrix();
	//glMatrixMode(GL_PROJECTION);
	//glLoadMatrixd(matrix);
	//glMatrixMode(GL_MODELVIEW);
	//glLoadIdentity();


	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(45, 1.9, 1, 10000);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glEnable(GL_TEXTURE_2D);
	

	glColor3f(1, 1, 1);

}

void PrintSmallText(float x, float y, float z, const std::string& text)
{
	glRasterPos3f(x, y, z);
	for (unsigned int k=0; k < text.size(); k++)
	{
		glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, text[k]);
	}
}

void PrintText3D(float x, float y, float z, const std::string& text)
{
	glRasterPos3f(x, y, z); 
	for (unsigned int k=0; k < text.size(); k++)
	{
		glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, text[k]);
	}
}